package com.yly.input.demo.converter;


import com.yly.input.demo.bo.ElderBO;
import com.yly.input.demo.repository.entity.Elder;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * 数据查询类型转换 entity -> BO
 */
@Service
public class BusinessConverter {

  public List<ElderBO> toElderBOList(List<Elder> elderList) {
    if (elderList == null || elderList.isEmpty()) {
      return null;
    }

    List<ElderBO> elderBOList = new ArrayList<>();
    for (Elder elder : elderList) {
      ElderBO elderBO = new ElderBO();
      BeanUtils.copyProperties(elder, elderBO);
      elderBOList.add(elderBO);
    }
    return elderBOList;
  }
}
